package com.java;

/**
 * Hello world!
 *
 */
public class MementoPatternDemo
{
    public static void main( String[] args )
    {
        Originator originator=new Originator();
        CarTaker carTaker=new CarTaker();
        originator.setState("State #1");
        originator.setState("State #2");
        carTaker.add(originator.saveStateToMemento());
        originator.setState("State #3");
        carTaker.add(originator.saveStateToMemento());
        originator.setState("State #4");

        System.out.println("Current State:"+originator.getState());
        originator.getStateFromMemento(carTaker.get(0));
        System.out.println("First saved State:"+originator.getState());
        originator.getStateFromMemento(carTaker.get(1));
        System.out.println("Second saved State:"+originator.getState());
    }
}
